import requests
from PIL import Image
from io import BytesIO

save_path = r"D:\myself\爬虫数据\output.jpg"

url='https://f40-1-4.g-mh.online/scomic/jinhuakuangchao-mokf/0/153-3w6y/4.webp'
headers = {
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0',
    'referer':'https://manhuafree.com/'
}

res = requests.get(url=url,headers=headers)
if res.status_code == 200:
    img = Image.open(BytesIO(res.content))
    img.show()

    with open(save_path, "wb") as f:
        f.write(res.content)
    print("图片已保存为 output.jpg")
else:
    print("请求失败，状态码:", res.status_code)